<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib prefix="fmt" 
           uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>我的商城</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath }/html/css/style.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath }/html/css/login.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath }/html/css/invest.css">
	<script src="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js">
	</script>
	<style>
		.select {
				  width:auto; margin-top:12px; 
			      font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
			      font-size:11px; 
			      color:#999999;
			      line-height:25px;
			      letter-spacing:1px

			}
	</style>
</head>
<body>
  <div class="wrap" style="background-color:#f7f7f7;">
    <div class="header">
     <div class="top">
      <ul id="nav">
        <li><a href="${pageContext.request.contextPath }/user/car"><span>返回购物车</span></a></li>
      </ul>
    </div><!--top-->
    </div><!--header-->

    <div class="main">
        <div class="withdraw">
            <h3 style="float:left">订单列表 <span></span> 
            </h3>
        </div>
        <div class="invest" style="clear:both;">
            <ul id="investTitle">
          <c:if test="${enhanceList!=null}"> 
          <c:forEach items="${enhanceList}" var="enhance">
                <li class="count">
                    <p class="dkmc" style="font-size:25px">${enhance.goods.name}</p>
                    <div class="investCont">
                        <div style="width: 160px">
                            <p class="lilv">${enhance.discountsMessage.describe}</p>
                            <p class="investTit">商品优惠信息</p>
                        </div>
                        <div  style="width: 160px">
                            <p class="lilv" style="color: #858585">${enhance.goods.price}<span>元</span></p>
                            <p class="investTit">商品价格</p>
                        </div>
                        <div  style="width: 160px">
                            <p class="lilv" style="color: #858585">${enhance.car.goodsnum}<span>件</span></p>
                            <p class="investTit">购买数量</p>
                        </div>
                        <div  style="width: 160px">
                            <p class="lilv" style="color: #858585">${enhance.type.typename}</p>
                            <p class="investTit">商品类别</p>
                        </div>
                        <div  style="width: 160px">
                            <p class="lilv" style="color: #858585"><fmt:formatDate value="${enhance.goods.prodate}" pattern="yyyy-MM-dd"/></p>
                            <p class="investTit">生产日期</p>
                        </div>
                        <c:if test="${enhance.goods.effdate!=null&&enhance.goods.effdate!=''}">
	                        <div  style="width: 160px">
	                            <p class="lilv" style="color: #858585"><fmt:formatDate value="${enhance.goods.effdate}" pattern="yyyy-MM-dd"/></p>
	                            <p class="investTit">有效期</p>
	                        </div>
                        </c:if>
                        <c:if test="${enhance.goods.producer!=null&&enhance.goods.producer!=''}">
	                        <div  style="width: 160px">
	                            <p class="lilv" style="color: #858585">${enhance.goods.producer}</p>
	                            <p class="investTit">生产商</p>
	                        </div>
                        </c:if>
                        <c:if test="${enhance.goods.publisher!=null&&enhance.goods.publisher!=''}">
	                        <div  style="width: 160px">
	                            <p class="lilv" style="color: #858585">${enhance.goods.publisher}</p>
	                            <p class="investTit">出版社</p>
	                        </div>
                        </c:if>
                        <c:if test="${enhance.goods.size!=null&&enhance.goods.size!=''}">
	                        <div  style="width: 160px">
	                            <p class="lilv" style="color: #858585">${enhance.goods.size}</p>
	                            <p class="investTit">尺码</p>
	                        </div>
                        </c:if>
                        <div  style="width: 160px">
                            <p class="lilv" style="color: #858585">${enhance.goods.outdate}</p>
                            <p class="investTit">下架日期</p>
                        </div>
                        <div  style="width: 160px">
                            <p class="lilv" style="color: #858585" >
                            	<label class="price" >${enhance.goods.price*enhance.car.goodsnum}</label>
                            </p>
                            <p class="investTit">商品总价</p>
                        </div> 
                    </div>
                </li>
             </c:forEach> 
             </c:if>           
            </ul>
       	<h2 style="margin-left:820px;font-size:30px;margin-top:150px;width:500px">订单总价:<label id="price" style="font-size:30px"></label></h2>
		<button style="float: right;margin-right:8px;margin-top: 40px" onclick="mySubmit()">确认下单</button>
		<select id="address" name="address" style="float: right;margin-top: 40px">
			<option value="">请选择收货地址</option>
			<c:forEach 	items="${addressList}" var="myaddress">
				<option value="${myaddress.id}">${myaddress.province}${myaddress.city}${myaddress.address}-${myaddress.name}-${myaddress.phonenum}</option>
			</c:forEach>
		</select>
        </div>
    </div><!--main-->
</div><!--wrap-->
	
	
	<script>
		$(document).ready(function(){
			var price=0;
			var list=$(".price");
			$.each(list,function(index,content){
				price=parseInt($(content).text())+price;
			});
			$("#price").text(price);
		})
		function mySubmit()
		{
			if($("#address").val()==null||$("#address").val()==""){
				alert("请选择收货地址");
				return;
			}
			var a=confirm("是否确认下单?");
			console.log(a==true);
			if(a){
				window.open("${pageContext.request.contextPath }/user/insertOrder?addressId="+$("#address").val(), "_self");
			}
				
		}
	</script>
</body>
</html>
